package 蓝桥杯练习;

public class Main6 {

    public static void main(String[] args) {
        new Main6().run();
    }

    int N = 2020, ans = 0;

    private void run() {
        for (int i = 1; i <= N; i++)
            if (i % 10 == 2|
                    i / 10 % 10 == 2|
                    i / 100 % 10 == 2|
                    i / 1000 % 10 == 2) ans++;
        System.out.println(ans);
    }
}
